<template>
  <base-breadcrumb :title="$route.meta.title">
    <!-- 职工代表大会编辑 -->
    <a-form-model
      ref="ruleForm"
      :model="form"
      :label-col="{ span: 6 }"
      :wrapper-col="{ span: 18 }"
      :rules="rules"
    >
      <a-spin :spinning="loading">
        <!-- 表格 -->
        <a-card :bordered="false">
          <title-name title="基本信息"></title-name>
          <custom-form
            :formList="formList"
            :form="form"
            :is-emit="false"
            :editModel="editModel == 0 ? '' : ''"
          >
            <!-- 附件上传 -->
            <template #fileInfoList>
              <template v-if="editModel != 0">
                <l-table
                  businessCode="BM27"
                  :uploadArrys.sync="form.fileInfoList"
                ></l-table>
                <!-- <div class="file_prompt">支持扩展名：.rar .zip .doc .docx .pdf .jpg...</div> -->
              </template>
              <file-link
                v-else
                :fileList="form.fileInfoList"
                style="margin-top: -3px"
              ></file-link>
            </template>
          </custom-form>
        </a-card>
        <a-card :bordered="false">
          <title-name :title="taskDefKey != 'PDLSWJL' && taskDefKey != 'PDLXMJL' ? '项目经理意见' : '审批'"></title-name>
          <custom-form
            :formList="auditSWJL"
            :form="form"
            :editModel="editModel == 0 ? '' : ''"
          >
            <template #PDLXMJL>
              <a-form-model-item
                label=""
                class="item"
              >
                同意该同志在该项目补缴风险金
                <a-form-model-item
                  :colon="false"
                  label=" "
                  prop="pmPaymentAmount"
                  :style="{ display: 'inline-block' }"
                >
                  <a-input-number
                    :min="0"
                    style="width: 350px; margin-top: -34px"
                    placeholder="请输入"
                    :disabled="(taskDefKey != 'PDLSWJL' && taskDefKey != 'PDLXMJL' ) || editModel == 0"
                    v-model="form.pmPaymentAmount"
                  />
                </a-form-model-item>
                元
              </a-form-model-item>
            </template>
          </custom-form>
          <Consultation
            v-if="taskDefKey == 'PDLSWJL' || taskDefKey == 'PDLXMJL'"
            :proc-inst-id="procInstId"
            :is-show-btn="$route.query.isMonitoring ? ($route.query.monitoringType==='process' ? true: false): true"
            :task-name="taskName"
            :sub-approver-list.sync="subApproverList"
          >
            <template slot="approverButton">
              <a-button
                :loading="loading.PASS"
                @click="handleSave('PASS')"
              >审批通过</a-button>
              <a-button
                type="primary"
                class="ml12"
                :loading="loading.REJECT"
                @click="handleSave('REJECT')"
              >审批不通过</a-button>
            </template>
          </Consultation>
        </a-card>
        <a-card
          v-if="taskDefKey == 'BCSWFWBJL' || taskDefKey == 'BCLZJJS'"
          :bordered="false"
        >
          <title-name :title="taskDefKey != 'BCSWFWBJL' ? '分公司商务法务部经理意见' : '审批'"></title-name>
          <custom-form
            :formList="auditBCSWFWBJL"
            :form="form"
            :editModel="editModel == 0 ? '' : ''"
          >
            <template #BCSWFWBJL>
              <a-form-model-item
                label=""
                class="item"
              >
                同意该同志在该项目补缴风险金
                <a-form-model-item
                  :colon="false"
                  label=" "
                  prop="cldPaymentAmount"
                  :style="{ display: 'inline-block' }"
                >
                  <a-input-number
                    :min="0"
                    style="width: 350px; margin-top: -34px"
                    placeholder="请输入"
                    :disabled="taskDefKey != 'BCSWFWBJL' || editModel == 0"
                    v-model="form.cldPaymentAmount"
                  />
                </a-form-model-item>
                元
              </a-form-model-item>
            </template>
          </custom-form>
          <Consultation
            v-if="taskDefKey == 'BCSWFWBJL'"
            :proc-inst-id="procInstId"
            :is-show-btn="$route.query.isMonitoring ? ($route.query.monitoringType==='process' ? true: false): true"
            :task-name="taskName"
            :sub-approver-list.sync="subApproverList"
          >
            <template slot="approverButton">
              <a-button
                :loading="loading.PASS"
                @click="handleSave('PASS')"
              >审批通过</a-button>
              <a-button
                type="primary"
                class="ml12"
                :loading="loading.REJECT"
                @click="handleSave('REJECT')"
              >审批不通过</a-button>
            </template>
          </Consultation>
        </a-card>
        <a-card
          v-if="taskDefKey == 'BCLZJJS'"
          :bordered="false"
        >
          <title-name title="审批"></title-name>
          <custom-form
            :formList="auditBCLZJJS"
            :form="form"
            :editModel="editModel == 0 ? '' : ''"
          >
            <template #BCLZJJS>
              <a-form-model-item
                label=""
                class="item"
              >
                同意该同志在该项目补缴风险金
                <a-form-model-item
                  :colon="false"
                  label=" "
                  prop="economicsPaymentAmount"
                  :style="{ display: 'inline-block' }"
                >
                  <a-input-number
                    :min="0"
                    style="width: 350px; margin-top: -34px"
                    placeholder="请输入"
                    :disabled="editModel == 0"
                    v-model="form.economicsPaymentAmount"
                  />
                </a-form-model-item>
                元
              </a-form-model-item>
            </template>
          </custom-form>
          <Consultation
            :proc-inst-id="procInstId"
            :is-show-btn="$route.query.isMonitoring ? ($route.query.monitoringType==='process' ? true: false): true"
            :task-name="taskName"
            :sub-approver-list.sync="subApproverList"
          >
            <template slot="approverButton">
              <a-button
                :loading="loading.PASS"
                @click="handleSave('PASS')"
              >审批通过</a-button>
              <a-button
                type="primary"
                class="ml12"
                :loading="loading.REJECT"
                @click="handleSave('REJECT')"
              >审批不通过</a-button>
            </template>
          </Consultation>
        </a-card>
        <a-card>
          <template>
            <title-name title="审批流程信息" />
            <div class="btns-wrapp mb20">
              <a-button
                type="primary"
                @click="visibleState.auditProcess = true"
              > 审批流程图 </a-button>
            </div>
            <a-spin
              tip="流程信息加载中..."
              :spinning="flowRequesting"
            />
            <a-table
              :columns="columnApprove"
              :data-source="approveInfos"
              bordered
            >
              <span
                slot="serial"
                slot-scope="text, record, index"
              >{{ index + 1 }}</span>
              <template
                slot="opinions"
                slot-scope="text"
              >
                <a-tooltip placement="topLeft">
                  <template slot="title">
                    <span> {{ text }}</span>
                  </template>
                  <span> {{ text }}</span>
                </a-tooltip>
              </template>
            </a-table>
          </template>
        </a-card>
      </a-spin>
      <!-- 页脚操作栏 -->
      <div class="btn_box page-btn-right-top">
        <a-button
          type="primary"
          @click="handleActiveClose"
        >关闭</a-button>
      </div>
    </a-form-model>
     
    <ApprovalDetails
      :title="'审批流程信息'"
      :business-id="id"
      :visible="visibleState.auditProcess"
      @cancel="visibleState.auditProcess = false"
      @confirm="visibleState.auditProcess = false"
    />
  </base-breadcrumb>
</template>

<script>
import { insertSelective, updateByPrimaryKeySelective, getCommercialPerSupplementaryPaymentById } from '@/api/businessAffairs/riskRefund'

import BaseEditPage from '@/views/baseEditPage' // 编辑详情页基础配置
import SelectPersonModal from '@/components/SelectPersonModal'
import SelectSubCompany from '@/components/Select/SelectSubCompany' // 分公司
import SelectProject from '@/components/Select/SelectProject' // 分公司
import moment from 'moment'
import SelectPersonByProject from '@/components/Select/SelectPersonByProject' // 分公司
import SelectProjectJob from '@/components/Select/SelectProjectJob' // 项目
import { paymentList, columnApprove } from './model.js'
import ApprovalDetails from '@/components/approvalDetails'
import { getOrgEmployeesListBy } from '@/api/commons'
import { getProcessNodeList, completeTask } from '@/api/process'
import Consultation from '@/views/matters/approval/components/consultation'
import Vue from 'vue'
export default {
  name: 'a' + Date.now(),
  extends: new BaseEditPage(),
  components: {
    SelectPersonModal,
    SelectPersonByProject,
    SelectProjectJob,
    SelectProject,
    ApprovalDetails,
    Consultation
  },
  data() {
    return {
      columnApprove,
      visibleState: {
        auditProcess: false
      },
      loading: false, // 加载控件
      visible: false, //人员选择控件
      editModel: 0, // 操作状态:0 查看;1 编辑;2 新增
      form: {
        projectDeptId: void 0,
        opinions: '同意',
        opinionsXMJL: '同意',
        opinionsBCSWFWBJL: '同意',
        opinionsBCLZJJS: '同意'
      }, // 表单
      id: '',
      loadingBtn: {
        DELETE: false,
        DRAFT: false,
        SUBMITTED: false,
        REJECTED: false
      },
      rules: {
        proposerId: [{ required: true, message: '请选择' }],
        proposerPostId: [{ required: true, message: '请选择' }],
        idCard: [{ required: true, message: '请输入' }],
        paymentAmount: [{ required: true, message: '请输入' }],
        paymentReason: [{ required: true, message: '请选择' }],
        bankAccount: [{ required: true, message: '请输入' }],
        bankName: [{ required: true, message: '请输入' }],
        paymentConditions: [{ required: true, message: '请输入' }],
        opinionsXMJL: [{ required: true, message: '请输入' }],
        opinionsBCSWFWBJL: [{ required: true, message: '请输入' }],
        opinionsBCLZJJS: [{ required: true, message: '请输入' }],
        pmPaymentAmount: [{ required: true, message: '请输入' }],
        cldPaymentAmount: [{ required: true, message: '请输入' }],
        economicsPaymentAmount: [{ required: true, message: '请输入' }],
        fileInfoList: [{ type: 'array', required: true, message: '请上传附件', trigger: 'blur' }]
      }, // 校验规则
      init: false, // 初始化控件

      //审批相关
      approveInfos: [], // 审批流程信息
      procInstId: '', //当前流程实例ID
      taskId: '', //当前流程节点ID
      processName: '', //流程名称
      taskName: '', //当前流程节点名称
      taskDefKey: '', //任务标识
      currentTime: '', //当前审批时间
      currentUser: '', //当前审批人
      flowRequesting: false,
      detailUrl: null, //详情地址

      assignType: '', //节点类型   0 变量获取 1 处理人 2 候选人 3 候选组 4 会签
      assignCode: '', //候选组编码 岗位编码
      assignLevel: '', //层级 项目部 PD 分公司 BC 公司 CO
      businessType: '', //业务类型 0 项目
      // 下级审批人
      subApproverList: [],
      // 流程监控查看
      monitoringDetail: this.$route.query.hasOwnProperty('isMonitoring') && !this.$route.query.hasOwnProperty('monitoringType')
    }
  },
  props: {
    isAudit: {
      // 是否作为审批详情
      type: Boolean,
      default: false
    }
  },
  watch: {
    // 监听附件实现附件校验
    'form.fileInfoList'() {
      if (this.editModel != 0 && this.init) {
        this.$nextTick(() => {
          this.$refs.ruleForm?.validateField('fileInfoList')
        })
      }
    },
    isAudit: {
      immediate: true,
      handler(val) {
        if (val) {
          this.$nextTick(() => {
            this.editModel = 0
          })
        }
      }
    }
  },
  mounted() {
    this.formattingData() //格式化审批流数据
  },
  computed: {
    formList() {
      return [
        {
          type: SelectSubCompany,
          keyName: 'branchComId',
          label: '分公司名称',
          disabled: true,
          attrs: {
            isDefaultSelected: this.editModel == 2,
            autoSelected: this.editModel == 2
          }
        },
        {
          type: SelectProject,
          keyName: 'projectId',
          label: '项目名称',
          disabled: true,
          attrs: {
            isDefaultSelected: this.editModel == 2,
            autoSelected: this.editModel == 2,
            keyValue: 'branchComId',
            isClear: this.editModel == 2,
            isEdit: this.editModel != 2,
            form: this.form
          },
          selectChange: (e) => {
            this.form.projectDeptId = e?.projectDeptId
          }
        },
        {
          keyName: 'proposerId',
          type: SelectPersonByProject,
          disabled: this.editModel == 0,
          label: '补缴申请人',
          attrs: {
            // [currentLabel.sync]: form.returnApplier,
            isOrg: true,
            showSearch: true,
            orgId: this.form.projectDeptId,
            mode: 'combobox',
            optionLabelProp: 'children'
          },
          personChanged: (e) => {
            this.form.proposerName = e?.employeeName
          }
        },

        {
          keyName: 'proposerPostId',
          type: SelectProjectJob,
          disabled: this.editModel == 0,
          label: '申请人岗位',
          attrs: {
            projectDeptId: this.form.projectDeptId,
            isClear: this.editModel == 2
          },
          getOption: (e) => {
            this.form.proposerPostName = e?.name
          }
        },
        {
          keyName: 'idCard',
          type: 'BaseInput',
          disabled: this.editModel == 0,
          label: '身份证号码'
        },
        {
          keyName: 'paymentAmount',
          type: 'BaseInputNumber',
          disabled: this.editModel == 0,
          label: '补缴金额(元)'
        },
        {
          keyName: 'paymentReason',
          type: 'a-select',
          label: '补缴原因',
          disabled: this.editModel == 0,
          data: paymentList
        },
        {
          keyName: 'bankAccount',
          type: 'BaseInput',
          disabled: this.editModel == 0,
          label: '银行账号'
        },
        {
          keyName: 'bankName',
          type: 'BaseInput',
          disabled: this.editModel == 0,
          label: '开户行名称'
        },
        {
          keyName: 'paymentConditions',
          type: 'BaseTextarea',
          label: '补缴情况说明',
          disabled: this.editModel == 0,

          span: 24
        },
        {
          slot: true,
          keyName: 'fileInfoList',
          label: '附件上传',
          span: 24
        }
      ]
    },
    auditSWJL() {
      return [
        {
          slot: true,
          customItemSlot: true,
          keyName: 'PDLXMJL',
          hidden: this.taskDefKey == 'PDLSWJL',

          span: 24
        },
        {
          keyName: 'opinionsXMJL',
          type: 'BaseTextarea',
          label: '审批意见',
          disabled: (this.$route.query.editModel&&this.$route.query.editModel == 0) || (this.taskDefKey != 'PDLSWJL' && this.taskDefKey != 'PDLXMJL'),
          span: 24
        },

        {
          keyName: 'taskName',
          type: 'BaseInput',
          label: '当前节点名称',
          disabled: true,
          hidden: this.taskDefKey != 'PDLSWJL' && this.taskDefKey != 'PDLXMJL',
          span: 8
        },
        {
          keyName: 'currentUser',
          type: 'BaseInput',
          label: '审批人',
          disabled: true,
          hidden: this.taskDefKey != 'PDLSWJL' && this.taskDefKey != 'PDLXMJL',
          span: 8
        },
        {
          keyName: 'currentTime',
          type: 'BaseInput',
          label: '审批时间',
          disabled: true,
          hidden: this.taskDefKey != 'PDLSWJL' && this.taskDefKey != 'PDLXMJL',
          span: 8
        },
        {
          keyName: 'durationInMillis',
          type: 'BaseInput',
          label: '当前滞留时间',
          disabled: true,
          hidden: this.taskDefKey != 'PDLSWJL' && this.taskDefKey != 'PDLXMJL',
          span: 8
        }
      ]
    },
    auditBCSWFWBJL() {
      return [
        {
          slot: true,
          customItemSlot: true,
          keyName: 'BCSWFWBJL',
          span: 24
        },
        {
          keyName: 'opinionsBCSWFWBJL',
          type: 'BaseTextarea',
          label: '审批意见',
          disabled: this.taskDefKey != 'BCSWFWBJL',
          span: 24
        },
        {
          keyName: 'taskName',
          type: 'BaseInput',
          label: '当前节点名称',
          disabled: true,
          span: 8
        },
        {
          keyName: 'currentUser',
          type: 'BaseInput',
          label: '审批人',
          disabled: true,
          span: 8
        },
        {
          keyName: 'currentTime',
          type: 'BaseInput',
          label: '审批时间',
          disabled: true,
          span: 8
        },
        {
          keyName: 'durationInMillis',
          type: 'BaseInput',
          label: '当前滞留时间',
          disabled: true,
          span: 8
        }
      ]
    },
    auditBCLZJJS() {
      return [
        {
          slot: true,
          customItemSlot: true,
          keyName: 'BCLZJJS',
          span: 24
        },
        {
          keyName: 'opinionsBCLZJJS',
          type: 'BaseTextarea',
          label: '审批意见',

          span: 24
        },
        {
          keyName: 'taskName',
          type: 'BaseInput',
          label: '当前节点名称',
          disabled: true,
          span: 8
        },
        {
          keyName: 'currentUser',
          type: 'BaseInput',
          label: '审批人',
          disabled: true,
          span: 8
        },
        {
          keyName: 'currentTime',
          type: 'BaseInput',
          label: '审批时间',
          disabled: true,
          span: 8
        },
        {
          keyName: 'durationInMillis',
          type: 'BaseInput',
          label: '当前滞留时间',
          disabled: true,
          span: 8
        }
      ]
    }
  },
  methods: {
    //流程节点信息
    getProcessNodes() {
      this.flowRequesting = true
      getProcessNodeList({ procInstId: this.procInstId, pageNo: 1, pageSize: 100 })
        .then((res) => {
          if (res.code === 200) {
            const data = res.data.map((d) => {
              if (d.formData) {
                d.formData = JSON.parse(d.formData)
              }
              return d
            })
            const userIds = data.map((d) => {
              return d.assignee
            })
            getOrgEmployeesListBy({ userIds, delete: true }).then((employees) => {
              this.flowRequesting = false
              data.forEach((r) => {
                employees.data.some((e) => {
                  if (e.userId === r.assignee) {
                    r.userName = e.name
                    return true
                  }
                })
              })
              // if (data.length == 2) {
              //   this.form.opinionsXMJL = data[1].formData.opinions
              // }
              // if (data.length == 3) {
              //   this.form.opinionsXMJL = data[2].formData.opinions
              // }
              data.forEach((el) => {
                switch (el?.taskDefKey) {
                  case 'PDLSWJL':
                    this.form.opinionsXMJL = el?.formData?.opinions
                    break
                  case 'PDLXMJL':
                    this.form.opinionsXMJL = el?.formData?.opinions
                    break
                  case 'BCSWFWBJL':
                    this.form.opinionsBCSWFWBJL = el?.formData?.opinions
                    break
                  case 'BCLZJJS':
                    this.form.opinionsBCLZJJS = el?.formData?.opinions
                    break
                }
              })
              if (this.$route.query.taskDefKey === 'PDLXMJL') {
                this.form.opinionsXMJL = '同意'
              }

              this.approveInfos = data
            })
          }
        })
        .catch(() => {
          this.flowRequesting = false
        })
    },
    formattingData() {
      try {
        setTimeout(() => {
          const requireDom = document.querySelectorAll('.ant-form-item-required')
          requireDom.forEach((item) => {
            item.parentNode.nextSibling.children[0].children[0].classList.add('requiredFormItem') // 找到'.ant-form-item-children'元素添加样式
          })
        }, 0)
      } catch {}
      this.form.user = JSON.parse(sessionStorage.getItem('ycloud-user_info')).username
      this.id = this.$route.query.id
      const { type, code, level, btype, businessId, procInstId, name, processName, detailUrl, taskId, taskDefKey, durationInMillis } = this.$route.query
      if (type) {
        this.assignType = type
        this.assignCode = code
        this.assignLevel = level
        this.businessType = btype
      }
      this.id = businessId
      // this.taskDefKey = 'GS_CWZJBJL_AUDIT'
      if (!this.id) {
        this.$error({ content: '无指定业务ID，将自动关闭' })
        setTimeout(() => {
          window.close()
        }, 1500)
        return
      }
      console.log(this.$route.query)
      this.procInstId = procInstId
      this.form.currentUser = Vue.getAcloudProvider().getUserInfo().name
      this.form.taskName = decodeURIComponent(name)
      this.taskName = this.form.taskName
      this.form.durationInMillis = durationInMillis
      this.processName = decodeURIComponent(processName)
      document.title = this.processName + '-' + this.form.taskName
      if (detailUrl) {
        this.detailUrl = decodeURIComponent(detailUrl)
      }
      this.taskId = taskId
      this.taskDefKey = taskDefKey

      this.form.currentTime = moment().format('yyyy-MM-DD HH:mm')
      this.$route.meta.title = '个人风险金补缴审批'
      this.getCommercialPerSupplementaryPaymentByIdReq()
    },
    //获取业务详情
    getCommercialPerSupplementaryPaymentByIdReq() {
      // 不为添加时请求详情
      if (this.editModel != 2) {
        this.loading = true
        getCommercialPerSupplementaryPaymentById({ id: this.id })
          .then((res) => {
            this.loading = false
            console.log(res)
            this.form = { ...this.form, ...res.data }
            if (this.taskDefKey == 'PDLSWJL' || this.taskDefKey == 'PDLXMJL') {
              this.form.opinionsXMJL = '同意'
            } else if (this.taskDefKey == 'BCSWFWBJL') {
              this.form.opinionsBCSWFWBJL = '同意'
            } else if (this.taskDefKey == 'BCLZJJS') {
              this.form.opinionsBCLZJJS = '同意'
            }
            console.log(this.form)

            this.$nextTick(() => {
              this.init = true
              this.getProcessNodes()
            })
          })
          .catch(() => {
            this.loading = false
          })
      } else {
        this.$nextTick(() => {
          this.init = true
          this.getProcessNodes()
        })
      }
    },
    validateForm() {
      let flag = false
      this.$refs.ruleForm.validate((e) => {
        if (e) {
          flag = true
        } else {
          this.$message.warning('请填写完所有必填项信息')
        }
      })

      return flag
    },
    // 处理增、删、改操作
    handleSave(status) {
      if (this.loadingBtn[status]) return

      if (status == 'PASS') {
        if (this.validateForm()) {
          this.handelApproval(status)
        }
      } else {
        this.handelUnApproval(status)
      }
    },
    handelApproval(staus) {
      // 审批通过
      const _this = this
      const confirmWin = this.$confirm({
        title: '警告提醒！',
        content: '确定审批通过？',
        okType: 'danger',
        onOk() {
          return new Promise((resolve, reject) => {
            _this
              .submit(false, _this.createApproverList(_this.subApproverList))
              .then(() => {
                resolve()
                confirmWin.destroy()
              })
              .catch((err) => reject())
          }).catch((err) => {
            console.log(err)
            _this.$error({ content: '审批提交失败，请稍后重试' })
          })
        },
        onCancel() {}
      })
    },
    notifyParent() {
      window.opener.postMessage('finish', window.location.origin)
    },
    handelUnApproval(staus) {
      // 审批不通过
      const _this = this
      const confirmWin = this.$confirm({
        title: '警告提醒！',
        content: '确定审批不通过？',
        okType: 'danger',
        onOk() {
          return new Promise((resolve, reject) => {
            _this
              .submit(true)
              .then(() => {
                resolve()
                confirmWin.destroy()
              })
              .catch(() => reject)
          }).catch(() => _this.$error({ content: '审批提交失败，请稍后重试' }))
        },
        onCancel() {}
      })
    },

    /**
     * @description: 组装下级审批人数据
     * @param {array} subApproverList 下级审批人表格数据
     * @return {object} 下级审批人数据
     */
    createApproverList(subApproverList) {
      const subordinateApproverList = {}
      subApproverList.forEach((item) => {
        if (item?.approver && item.approver.length > 0) {
          subordinateApproverList[item.taskInfo.id] = {
            assgins: item.approver?.map((el) => el.key).join(','),
            assignTypeEnum: 2
          }
        }
      })
      return subordinateApproverList
    },
    /**
     * @description: 审批
     * @param {boolean} reject 是否不通过
     * @param {object} subordinateApproverList 下级审批人
     * @return {promise}
     */
    async submit(reject, subordinateApproverList = {}) {
      delete this.form.auditStatus
      switch (this.taskDefKey) {
        case 'PDLSWJL':
          this.form.opinions = this.form.opinionsXMJL
          delete this.form.opinionsXMJL
          break
        case 'PDLXMJL':
          this.form.opinions = this.form.opinionsXMJL
          await updateByPrimaryKeySelective(this.form)
          break
        case 'BCSWFWBJL':
          this.form.opinions = this.form.opinionsBCSWFWBJL
          await updateByPrimaryKeySelective(this.form)
          break
        case 'BCLZJJS':
          this.form.opinions = this.form.opinionsBCLZJJS
          await updateByPrimaryKeySelective(this.form)
          break
      }

      const data = {
        formData: {
          opinions: this.form.opinions,
          reject
        },
        procInstId: this.procInstId,
        taskId: this.taskId,
        userId: Vue.getAcloudProvider().getUserInfo().id,
        variables: {
          reject,
          ...this.submitData,
          ...subordinateApproverList
        }
      }
      return completeTask(data)
        .then((res) => {
          if (res.status === 200) {
            this.notifyParent() // 通知父窗口
            // this.$success({
            //   content: '审批提交成功，即将自动关闭当前窗口',
            //   onOk() {
                window.close()
            //   }
            // })
            // setTimeout(() => {
            //   window.close()
            // }, 2000)
          } else {
            this.$error({ content: '审批提交失败，请稍后重试' })
          }
          return res
        })
        .catch((err) => {
          console.log(err)
          return err
        })
    }
  }
}
</script>
<style lang="less" scoped>
/deep/ .form-item  {
  .ant-input:not([disabled]),
  .ant-select:not(.ant-select-disabled) .ant-select-selection,
  .ant-calendar-picker-input,
  .ant-input-number:not([disabled]),
  .ant-cascader-picker {
    border-color: #e4ac0b;
    background-color: #fff9e8;
  }
  .remark {
    .ant-input {
      border-color: inherit;
      background-color: initial;
    }
  }
}
.item {
  margin-left: 60px;
  margin-bottom: 0;
}
.item .ant-form-item {
  margin-top: -28px;
}
</style>
